{layout name="ucenter/layout" /}

<style>
  /*分页样式*/
  .pagination{text-align:center;margin-top:20px;margin-bottom: 20px;}
  .pagination li{margin:0px 10px; border:1px solid #e6e6e6;padding: 6px 12px;display: inline-block;}
  .pagination li:hover{background:#e6e6e6 }
  .pagination .active{background-color: #dd1a20;color: #fff;}
  .pagination .disabled{color:#aaa;}
</style>
<table class="layui-table">
  <colgroup>
    <col width="150">
    <col width="200">
    <col>
  </colgroup>
  <thead>
    <tr>
      <th>封面</th>
      <th>标题</th>
      <th>分类</th>
      <th>阅读量</th>
      <th>创建时间</th>
      <th>管理</th>
    </tr> 
  </thead>
  <tbody>
    {volist name="articleList" id="vo"}
    <tr>
      <td><img style="width:100px;height:80px" src="{$vo.img|default='/uploads/default/default_cover.jpg'}" /></td>
      <td>{$vo.title}</td>
      <td>{$vo.tagName}</td>
      <td>{$vo.read_count}</td>
      <td>{$vo.create_time|date="Y-m-d",###}</td>
      <td>
        <div class="layui-btn-group">
          <a href="release?id={$vo.article_id}" class="layui-btn layui-btn-primary layui-btn-sm">
            <i class="layui-icon">&#xe642;</i>
          </a>
          <button onclick="delectAritcle('{$vo.article_id}',this)" class="layui-btn layui-btn-primary layui-btn-sm">
            <i class="layui-icon">&#xe640;</i>
          </button>
        </div>
      </td>
    </tr>
    {/volist}
  </tbody>
</table>
{empty name="articleList"}<p style="color:red;text-align: center">你还没有发布过内容喔</p>{/empty}
{$articleList->render()}
<script>
  layui.use('layer');              
  function delectAritcle(articleId,obj){
    layer.msg('确定删除？', {
      time: 0 //不自动关闭
      ,btn: ['删除', '取消']
      ,yes: function(index){
        $.ajax({
          type:"post",
          data:"articleId="+articleId,
          url:"/admin/article/delete",
          success:function(e){
            if(e.code == 1){
              window.location.reload();
              layer.msg(e.msg,{icon:1});
            }else{
              layer.msg(e.msg);
            }
          }
        });
        layer.close(index);
      }
    });
  }
</script>